package com.mew.chess.core.common.handler;


import com.mew.chess.core.common.message.request.BetRequestMessage;
import com.mew.chess.core.common.message.request.EnterGameRequestMessage;
import com.mew.chess.core.common.message.request.GiftRequestMessage;
import com.mew.chess.core.common.message.request.ReconnectionGameRequestMessage;
import com.mew.chess.core.game.pokdeng.game.message.AskRequest;
import com.mew.chess.core.game.pokdeng.game.message.PokDengBetRequest;
import com.mew.chess.core.game.qmcs.game.message.QmcsKillResponseMessage;
import com.mew.chess.core.game.qmcs.game.message.request.QmcsHitRequestMessage;
import com.mew.chess.core.game.shbz.game.message.ArtilleryDropMessage;
import com.mew.chess.core.game.shbz.game.message.LockResponseMessage;
import com.mew.chess.core.game.shbz.game.message.request.FireRequestMessage;
import com.mew.chess.core.game.shbz.game.message.request.HitRequestMessage;
import com.mew.chess.core.game.shbz.game.message.request.SwitchBetRequestMessage;
import com.mew.chess.core.game.shbz.game.message.request.SwitchCannonRequestMessage;
import com.zebra.remoting.config.EmptyMessage;
import com.zebra.remoting.protocol.CommandCode;
import com.zebra.remoting.protocol.CommandType;
import com.zebra.remoting.protocol.PoolType;
import com.zebra.remoting.protocol.ProcessorType;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;


public enum ChessHandlerMapCmdType implements CommandCode {

    EnterRoom(6000, ProcessorType.G_LOGIN,  PoolType.EXECUTOR,  true, EnterGameRequestMessage.class), // "EnterRoom"
    ReconnectRoom(6001,  ProcessorType.G_RECON,  PoolType.EXECUTOR,  true, ReconnectionGameRequestMessage.class), // "EnterRoom"
    ExitRoom(6009, ProcessorType.G_EXIT,  EmptyMessage.class),

    Gift(6010, ProcessorType.GM,  GiftRequestMessage.class),

    /**  ---------- 400X--4049-- - 百人场----25---------- */
    BrnnBet(4000, ProcessorType.GM, BetRequestMessage.class), // bet
    BrnnBetCancel(4001, ProcessorType.GM, EmptyMessage.class), //取消押注
    BrnnApplyBanker(4026, ProcessorType.GM, EmptyMessage.class), //申请上庄
    BrnnApplyOutBanker(4027, ProcessorType.GM,  EmptyMessage.class), //  "申请下庄"),
    BrnnOnlineList(4028,  ProcessorType.GM, EmptyMessage.class),  // "在线用户列表"),

    YxxBet(4050, ProcessorType.GM, BetRequestMessage.class), // bet
    YxxGift(4051, ProcessorType.GM,  GiftRequestMessage.class),

    BjlBet(4100,ProcessorType.GM, BetRequestMessage.class),// bet
    BjlCancle(4101,ProcessorType.GM,EmptyMessage.class),//取消押注
    BjlGift(4102, ProcessorType.GM,  GiftRequestMessage.class),

    PokDengBet(4150,ProcessorType.GM, PokDengBetRequest.class),//押注
    PokDengAsk(4151,ProcessorType.GM, AskRequest.class),//取消押注
    PokDengGift(4152, ProcessorType.GM,  GiftRequestMessage.class),

    DyjBet(4200,ProcessorType.GM, BetRequestMessage.class),// bet
    DyjCancle(4201,ProcessorType.GM,EmptyMessage.class),//取消押注
    DyjGift(4202, ProcessorType.GM,  GiftRequestMessage.class),

    PmBet(4250, ProcessorType.GM, BetRequestMessage.class), // bet

    LhBet(4500, ProcessorType.GM, BetRequestMessage.class), // bet
    LhGift(4501, ProcessorType.GM,  GiftRequestMessage.class),



    //other
//    otherBet(10300, true, BetRequestMessage.class),

    // 二十一点201: 请求命令[20100-20149];  推送命令[20150-20199]
    BlackjackBet(10300, ProcessorType.GM, BetRequestMessage.class),

    //通比牛牛202: 请求命令[20200-20249];  推送命令[20250-20299]
    TbnnBet(10400, ProcessorType.GM, BetRequestMessage.class),

    // 501*
    ShbzBet(5000,ProcessorType.GM, HitRequestMessage.class),
    ShbzFire(5001,ProcessorType.GM, FireRequestMessage.class),
    ShbzLock(5002,ProcessorType.GM, LockResponseMessage.class),
    ShbzDrop(5003,ProcessorType.GM, ArtilleryDropMessage.class),
    ShbzSwitchBet(5004,ProcessorType.GM, SwitchBetRequestMessage.class),
    ShbzSwitchCannon(5005,ProcessorType.GM, SwitchCannonRequestMessage.class),

    QmcsBet(5050,ProcessorType.GM, QmcsHitRequestMessage.class);

    private int cmd ;
    private CommandType commandType;
    private ProcessorType processorType;
    private PoolType poolType;
    private boolean verifyType;
    private final Class request;

    ChessHandlerMapCmdType(int cmd, ProcessorType processorType, PoolType poolType,  boolean verifyType,  Class request){
        this.cmd = cmd;
        this.processorType = processorType;
        this.poolType = poolType;
        this.verifyType = verifyType;
        this.request = request;
        this.commandType = CommandType.GAME;
    }


    ChessHandlerMapCmdType(int cmd, ProcessorType processorType, Class request){
        this.cmd = cmd;
        this.processorType = processorType;
        this.request = request;
        this.verifyType = true;
        this.commandType = CommandType.GAME;
        this.poolType = PoolType.DISRUPTOR;
    }

    @Override
    public int cmd() {
        return this.cmd;
    }

    @Override
    public ProcessorType processorType() {
        return this.processorType;
    }

    @Override
    public Class request() {
        return this.request;
    }


    @Override
    public PoolType poolType() {
        return this.poolType;
    }

    @Override
    public boolean verifyType() {
        return this.verifyType;
    }

    @Override
    public CommandType commandType() {
        return this.commandType;
    }

    //转换成 map
    private  static Map<Integer, CommandCode> handlerTypeMap = Arrays.stream(ChessHandlerMapCmdType.values())
            .collect(Collectors.toMap(ChessHandlerMapCmdType::cmd, rtype -> rtype));

    public  static ChessHandlerMapCmdType valueOfCode(int cmd){
        return (ChessHandlerMapCmdType) handlerTypeMap.get(cmd);
    }

    public  static Map<Integer, CommandCode> getMap(){
        return handlerTypeMap;
    }


}
